package com.concurrent.chapter4.concurrent07;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程池
 */
public class Run1 {
	public static void main(String[] args) {
		int corePoolSize = 7;
		int maximumPoolSize = 8;
		int keepAliveTime = 5;
		TimeUnit unit = TimeUnit.SECONDS;
		LinkedBlockingDeque<Runnable> workQueue = new LinkedBlockingDeque<>();
		ThreadPoolExecutor executor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
		System.out.println(executor.getCorePoolSize());//7
		System.out.println(executor.getMaximumPoolSize());//8
		System.out.println("---------------------------");
		SynchronousQueue<Runnable> synchronousQueue = new SynchronousQueue<>();
		executor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit, synchronousQueue);
		System.out.println(executor.getCorePoolSize());//7
		System.out.println(executor.getMaximumPoolSize());//8
	}
}
